//
//  XQWelcomeCell.m
//  JoinPeso
//
//  Created by 小琦 on 2024/11/19.
//

#import "XQWelcomeCell.h"
#import "XQHomeTabBarController.h"

@interface XQWelcomeCell()

@property (nonatomic,strong) UIButton *nextButton;

@end

@implementation XQWelcomeCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.contentView.backgroundColor = [UIColor colorWithHexString:@"#D8EBFF"];
        [self makeUI];
        [self makeConstraints];
    }
    return self;
}

- (void)makeUI {
    [self.contentView addSubview:self.imageView];
    [self.contentView addSubview:self.nextButton];
}

- (void)makeConstraints {
    
    [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.insets(UIEdgeInsetsZero);
    }];
    
    [self.nextButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@12);
        make.right.equalTo(@-12);
        make.height.mas_equalTo(45);
        make.bottom.mas_equalTo(-113);
    }];
}

#pragma mark - setter

- (void)setIsLast:(BOOL)isLast {
    [self.nextButton setTitle:isLast ? @"Start" : @"Next" forState:UIControlStateNormal];
}

#pragma mark - private

- (void)nextClick {
    if (self.nextHandle) {
        self.nextHandle();
    }
}

#pragma mark - lazy

- (UIImageView *)imageView {
    if (!_imageView) {
        _imageView = [[UIImageView alloc] init];
    }
    return  _imageView;
}

- (UIButton *)nextButton {
    if (!_nextButton) {
        _nextButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _nextButton.backgroundColor = [UIColor colorWithHexString:@"#4C1DEE"];
        [_nextButton setTitle:@"Next" forState:UIControlStateNormal];
        _nextButton.titleLabel.font = [UIFont boldSystemFontOfSize:20];
        [_nextButton setTitleColor:kMainTextColor forState:UIControlStateNormal];
        _nextButton.layer.cornerRadius = 22.5;
        [_nextButton addTarget:self action:@selector(nextClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return  _nextButton;
}

@end
